﻿/* 
 * Since 2008 - 2013
 */

package com.hh.bss.sysadmin.service.impl;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;

import com.hh.bss.base.*;
import com.hh.bss.common.page.*;
import com.hh.bss.common.page.impl.*;
import com.hh.bss.sysadmin.dao.*;
import com.hh.bss.sysadmin.entity.*;
import com.hh.bss.sysadmin.service.*;
import com.hh.bss.sysadmin.vo.query.*;
import com.hh.bss.util.*;



@Service
@Transactional
public class SystemUserReportConfServiceImpl extends BaseBusinessService<SystemUserReportConf, java.lang.Integer> implements SystemUserReportConfService<SystemUserReportConf, java.lang.Integer> {

	private SystemUserReportConfDao systemUserReportConfDao;

	/** 增加setXXXX()方法,spring就可以通过autowire自动设置对象属性,请注意大小写 */
	public void setSystemUserReportConfDaoImpl(SystemUserReportConfDao dao) {
		this.systemUserReportConfDao = dao;
	}

	public EntityDao getEntityDao() {
		return this.systemUserReportConfDao;
	}

	@Transactional(readOnly = true)
	public Page findPage(SystemUserReportConfQuery query) {
		Page page = systemUserReportConfDao.findPage(query);
		if (query.getType() != null && query.getType() == 3700) { // 业绩指标
			Map m = systemUserReportConfDao.systemUserTargetSumTotal(query);
			DBUtil.sumXjTotal("typeName", page.getResult(), m, false, true);
		}

		return page;
	}

	public List findList(SystemUserReportConfQuery query) {
		List l = systemUserReportConfDao.findList(query);
		Map m = systemUserReportConfDao.systemUserTargetSumTotal(query);
		DBUtil.sumXjTotal("typeName", l, m, false, true);
		return l;
	}

	@Override
	public SystemUserReportConf getSystemUserReportConf(String account, Integer type) {
		// TODO Auto-generated method stub
		StringBuffer sql=new StringBuffer("from SystemUserReportConf t where t.account=? and t.type=?");
		List values=new ArrayList();
		values.add(account);
		values.add(type);
		List l=systemUserReportConfDao.getHibernateTemplate().find(sql.toString(), values.toArray());
		if (l!=null&&l.size()>0) return (SystemUserReportConf)l.get(0);
		return null;
	}

}
